package yiqiyihui.com.orderquery.ui;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import yiqiyihui.com.orderquery.R;
import yiqiyihui.com.orderquery.util.TitleBar;

/**
 * Created by Administrator on 2017/7/13.
 */

public class BaseActivity extends AppCompatActivity implements View.OnClickListener{
    private TitleBar mTitleBar;
    private ImageView imageView;
    private TextView backBtn;
    private TextView refreshBtn;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_base);
        initTittleBar();
        initView();
    }

    private void initTittleBar(){
        android.support.v7.app.ActionBar actionBar=getSupportActionBar();
        if(actionBar!=null) {
            actionBar.hide();
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // 透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

            imageView= (ImageView) findViewById(R.id.title_bar_img);

            int statusBarHeight1 = -1;
            //获取status_bar_height资源的ID
            int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
            if (resourceId > 0) {
                //根据资源ID获取响应的尺寸值
                statusBarHeight1 = getResources().getDimensionPixelSize(resourceId);
            }
            //Log.e("wangX", "状态栏:" + statusBarHeight1);
            ViewGroup.LayoutParams params = imageView.getLayoutParams();
            params.height=statusBarHeight1;
            imageView.setLayoutParams(params);
        }
    }

    private void initView(){
        backBtn= (TextView) findViewById(R.id.btnBack);
        refreshBtn= (TextView) findViewById(R.id.btnEdit);
        backBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btnBack:
                finish();
                break;
        }
    }

}
